﻿// -----------------------------------------------------------------------
// <copyright file="EventTSqlWriterTest.cs" company="YUMMO">
// Copyright (c) 2013 Lambert van Lieshout, YUMMO Software Development
// </copyright>
// -----------------------------------------------------------------------

namespace Yummo.BlackBox.Test
{
    using System;
    using Xunit;

    public class EventTSqlWriterTest
    {
        public string _connectionString = "Data Source=ds;Initial Catalog=db;User Id=lambert;Password=brabantsenachtenzijnlang";

        [Fact]
        public void CreateTSqlWriter()
        {
            Assert.DoesNotThrow(delegate
            {
                // Set up the log manager.
                BlackBoxManager log = new BlackBoxManager();

                // Creates a event writer for Microsoft SQL Server.
                EventTSqlWriter writer = new EventTSqlWriter("BlackBox", _connectionString);

                // Register the writer.
                log.RegisterWriter(BlackBoxUtilities.GetAllEventTypes(), writer.Write);

                // Write a event.
                log.Write(EventTypes.Trace, "Hello Test!");
            });
        }

        [Fact]
        public void CreateTSqlWriterFromConfig()
        {
            Assert.DoesNotThrow(delegate
            {
                // Set up the log manager.
                BlackBoxManager log = new BlackBoxManager();

                // Creates a event writer for Microsoft SQL Server from app.config.
                EventTSqlWriter writer = EventTSqlWriter.RegisterFromConfig(log);

                // Write a event.
                log.Write(EventTypes.Trace, "Hello Test!");
            });
        }
    }
}
